package com.sias.judgeservice.judge;

import com.sias.judgeservice.judge.strategy.DefaultJudgeStrategy;
import com.sias.judgeservice.judge.strategy.JavaLanguageJudgeStrategy;
import com.sias.judgeservice.judge.strategy.JudgeContext;
import com.sias.judgeservice.judge.strategy.JudgeStrategy;
import com.sias.model.model.codsandbox.JudgeInfo;
import com.sias.model.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @author 吴文杰
 * @version 1.0
 * @since 2023/12/10 20:53
 */
@Service
public class JudgeManager {

  /**
   * 执行判题
   *
   * @param judgeContext
   * @return
   */
  JudgeInfo doJudge(JudgeContext judgeContext) {
    QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
    String language = questionSubmit.getLanguage();
    JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
    if ("java".equals(language)) {
      judgeStrategy = new JavaLanguageJudgeStrategy();
    }
    return judgeStrategy.doJudge(judgeContext);
  }
}
